import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import store from './store'
import $ from 'jquery'

/*
 * 请求公共数据
 */
import common from '@/http/axios.js'


import '@/css/common.css'
import '@/css/set.css'
// import touch from './views/touch'
// Vue.use(touch);
import * as custom from './plugins/filters'
//vant 滚动组件
import { NoticeBar } from 'vant';
Vue.use(NoticeBar);
Vue.use(common);
import { List } from 'vant';
Vue.use(List);
Object.keys(custom).forEach(key => {
  Vue.filter(key, custom[key])
})

import basefun from './plugins/basefun'
Vue.use(basefun);

import {
  Loading
} from 'vant';

Vue.use(Loading);

import {
  Field
} from 'vant';

Vue.use(Field);
import {
  Cell,
  CellGroup
} from 'vant';

Vue.use(Cell).use(CellGroup);
import {
  PullRefresh
} from 'vant';
Vue.use(PullRefresh);

import {
  Popup
} from 'vant';
Vue.use(Popup);
import {
  Area
} from 'vant';
Vue.use(Area);

import {
  NavBar
} from 'vant';
Vue.use(NavBar);
Vue.use(Cell).use(CellGroup);
Vue.use(Area);
Vue.use(Popup);

import {
  Row,
  Col
} from 'vant';

Vue.use(Row).use(Col);
import {
  Icon
} from 'vant';

Vue.use(Icon);
import {
  Picker
} from 'vant';

Vue.use(Picker);
import {
  DatetimePicker
} from 'vant';

Vue.use(DatetimePicker);
import {
  Toast
} from 'vant';

Vue.use(Toast);

import {
  Button
} from 'vant';

Vue.use(Button);
import {
  Tab,
  Tabs
} from 'vant';

Vue.use(Tab).use(Tabs);
import { Dialog } from 'vant';

Vue.use(Dialog);
import {
  Progress
} from 'vant';
import './plugins/iview.js'

Vue.use(Progress);
Vue.config.productionTip = false
//路由跳转回到页面顶部
router.afterEach((to, from, next) => {
  if (to.path == '/dzx'||to.path == '/planList') {
    //监听是否需要关闭页面 (app)
    try {
      if (navigator.userAgent.indexOf('Android') > -1 ) {
          android.nativeCloseWebView("1"); //返回的时候关闭当前webView
          android.nativeMonitorButton("1","1"); //恢复物理返回键(成功页面会屏蔽返回键 )
      } else {
        window.webkit.messageHandlers.nativeCloseWebView.postMessage({
          back: "1"
        }); //返回的时候关闭当前webView
        window.webkit.messageHandlers.nativeMonitorButton.postMessage({
          back:"1",
          colse: "1"
        });
      }
    } catch (error) {
      
    }
  }else{
    try {
      if (navigator.userAgent.indexOf('Android') > -1 ) {
        android.nativeCloseWebView("0");
      } else {
        window.webkit.messageHandlers.nativeCloseWebView.postMessage({
          back: "0"
        });
      }
    } catch (error) {
      
    }

  }

  // document.body.scrollTop = 0;
  // document.documentElement.scrollTop =  0;
})
//为不同的页面切换title
router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title;
  next();
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')